home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Jugar con las fuentes / BlockFont / BlockFont.cs next >
Encoding:
Text File  |  2002-05-09  |  1.2 KB  |  38 lines

  1. //----------------------------------------
  2. // BlockFont.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class BlockFont: FontMenuForm
  9. {
  10.      const int iReps = 50;    // Aproximadamente 1/2 pulgada (exactamente en la impresora)
  11.  
  12.      public new static void Main()
  13.      {
  14.           Application.Run(new BlockFont());
  15.      }
  16.      public BlockFont()
  17.      {
  18.           Text = "Fuente bloque";
  19.           Width *= 2;
  20.           strText = "Bloque";
  21.           font = new Font("Times New Roman", 108);
  22.      }
  23.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  24.      {
  25.           SizeF sizef = grfx.MeasureString(strText, font);
  26.           float x     = (cx - sizef.Width  - iReps) / 2;
  27.           float y     = (cy - sizef.Height + iReps) / 2;
  28.  
  29.           grfx.Clear(Color.LightGray);
  30.  
  31.           for (int i = 0; i < iReps; i++)
  32.                grfx.DrawString(strText, font, Brushes.Black, x + i, y - i);
  33.  
  34.           grfx.DrawString(strText, font, Brushes.White, x + iReps, 
  35.                                                         y - iReps);
  36.      }
  37. }
  38.